package io.ooad.banking.dd.domain;

import javax.persistence.*;
import java.util.Date;

/**
 * 转入
 * Created by yyang on 16/9/16.
 */
@Entity
@DiscriminatorValue("T")
public class TransferInTransaction extends AccountTransaction {

    @OneToOne(mappedBy = "inTx")
    private TransferOutTransaction outTx;

    @ManyToOne
    @JoinColumn(name = "peer_account_id")
    private BankAccount debitAccount;

    TransferInTransaction() {
    }

    public TransferInTransaction(BankAccount account, TransferOutTransaction outTx, Money amount, Date date) {
        super(account, amount, date);
        this.outTx = outTx;
        this.debitAccount = outTx.getAccount();
    }

    public TransferOutTransaction getOutTx() {
        return outTx;
    }

    public BankAccount getDebitAccount() {
        return debitAccount;
    }
}
